/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bgu.sonar.util;

import bgu.sonar.util.ui.sat.SatellitsManager;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import org.openide.modules.ModuleInstall;
import org.openide.windows.WindowManager;

public class Installer extends ModuleInstall {

    @Override
    public void restored() {
        //REGISTER THE SATELITE MANAGER
        final SatellitsManager manager = new SatellitsManager();

        WindowManager.getDefault().getRegistry().addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                switch (evt.getPropertyName()) {
                    case "tcClosed":
                    case "tcOpened":
                    case "activated":
                        manager.sync();
                        break;
                }
            }
        });

        WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
            @Override
            public void run() {
                manager.sync();
            }
        });
    }
}
